home *** CD-ROM | disk | FTP | other *** search
/ PC World Interactive 7 / PC World Interactive 7.iso / program / ctutord.EXE / FILE1.C < prev    next >
C/C++ Source or Header  |  1991-12-04  |  572b  |  22 lines

  1. #include <stdio.h>
  2. main()
  3. {
  4.     FILE    *fp, *fopen();
  5.     static  char alpha[] = "abcdefghijklmnopqrstuvwxyz";
  6.     char    input[80];
  7.  
  8.     if( (fp=fopen("tempfile","w+")) == 0 ){
  9.         printf("Could not open the file: %s\n","tempfile");
  10.         exit(1);
  11.     }
  12.  
  13.     fprintf(fp,"%s",alpha); /* write out alphabet to "tempfile" */
  14.     printf("%d characters have been written\n",ftell(fp));
  15.     rewind(fp); /* set file positioning pointer to start of file */
  16.     fscanf(fp,"%s",input); /* read in file data */
  17.     printf("FILE DATA: %s\n",input); /* print out data */
  18.     fclose(fp);
  19. }
  20.  
  21.  
  22.